#!/bin/bash
# @file
#   .openshift/action_hooks/deploy

COMPOSER_DIR=${OPENSHIFT_DATA_DIR}"bin"

function install_composer() {
    echo 'Installing Composer'

    if [ ! -d "$COMPOSER_DIR" ]
    then
        mkdir -p $COMPOSER_DIR
    fi

    curl -s https://getcomposer.org/installer | php -- --install-dir=$COMPOSER_DIR
}

if [ ! -x "$COMPOSER_DIR/composer" ]
then
    install_composer
fi

$COMPOSER_DIR/composer.phar self-update
cd $OPENSHIFT_REPO_DIR
$COMPOSER_DIR/composer.phar install